#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenuBar* menuBar = this->menuBar();
    this->setMenuBar(menuBar);
    QMenu* menu = new QMenu("Document(&D)");
    menuBar->addMenu(menu);
    QToolBar* toolBar = new QToolBar();
    this->addToolBar(toolBar);
    QAction* action1 = new QAction("save document");
    QAction* action2 = new QAction("forget document");
    action1->setIcon(QIcon(":/p1.png"));
    action2->setIcon(QIcon(":/p2.png"));
    action1->setToolTip("kick this to save document");
    action2->setToolTip("open the forget document");
    toolBar->addAction(action1);
    toolBar->addAction(action2);
    menu->addAction(action1);
    menu->addAction(action2);
    connect(action1,&QAction::triggered,this,&MainWindow::handle1);
    connect(action2,&QAction::triggered,this,&MainWindow::handle2);

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::handle2()
{
    qDebug()<<"action2";
}

void MainWindow::handle1()
{
    qDebug()<<"action1";
}

